	clear matrix 
	clear
	set more off
	set seed 123456789
	capture log close
	log using "C:\Users\Patron\OneDrive - UW-Madison\Graduate School\Academics\Fall 2020\PA 888 Social Policy\SP\Analysis Feb 2021\Analysis for 2018\Postpsm\Child delivery\Log_delivery_postpsm.log", replace  // created a new log file 
	
	cd "C:\Users\Patron\OneDrive - UW-Madison\Graduate School\Academics\Fall 2020\PA 888 Social Policy\SP\Analysis Feb 2021\Analysis for 2018\Postpsm\Child delivery"  // setting the current directory
	clear
	
	use "C:\Users\Patron\OneDrive - UW-Madison\Graduate School\Academics\Fall 2020\PA 888 Social Policy\SP\PBS Processed Data\All provinces and regions\1314 and 1819 Combined Feb 2021\postpsm_deliverylocation_till_2018_vf.dta", replace
	
	
	
	keep if birth_year >= 2011
	keep if birth_year <= 2018
	
	keep if population_halves == 1
	
	
**************Location of birth*************************	
	
*****data for common trend assumption graph	*******

tabstat location_of_birth if treat == 1, by(birth_year)
tabstat location_of_birth if treat == 0, by(birth_year)

tab birth_year

*******testing common trend assumption via regression***************

gen time_trend = birth_year - 2011
gen inter_trend = time_trend*treat

local outputfile_common_trend commontrend_reg_bottom1.xls
set seed 12345678

bootstrap, reps(200): reg location_of_birth treat time_trend inter_trend birth_sequence hh_head_gender head_employment_status head_highest_grade hh_annual_income hh_annual_transfers hh_annual_exp_food_nondurables hh_annual_exp_durables hh_size dwelling_type occupancy_status distance_to_drinking_water drainage_sewerage_connection garbage_hh garbage_neighborhood drinking_water_source if time == 0, cluster(district) robust
outreg2 using `outputfile_common_trend'


***********summary table for DD for delivery location***********

ttest location_of_birth if treat == 1, by(time)
ttest location_of_birth if treat == 0, by(time)

local outputfile_dd_summary DD_child_delivery_summary_table.xls
set seed 123456789
bootstrap, reps(200): reg location_of_birth time treat did_estimator, cluster(district) robust
outreg2 using `outputfile_dd_summary' 


//creating dummy variable for each year for year fixed effects
 xi i.birth_year


*********DiD Estimations Tables for delivery location**************

local outputfile_dd_estimations did_delivery_bottom1.xls
set seed 123456789
bootstrap, reps(200): reg location_of_birth time treat did_estimator, cluster(district) robust
outreg2 using `outputfile_dd_estimations'

set seed 123456789
bootstrap, reps(200): reg location_of_birth time treat did_estimator _Ibirth_yea*, cluster(district) robust
outreg2 using `outputfile_dd_estimations'

set seed 123456789
bootstrap, reps(200): reg location_of_birth time treat did_estimator birth_sequence hh_head_gender head_employment_status head_highest_grade hh_annual_income hh_annual_transfers hh_annual_exp_food_nondurables hh_annual_exp_durables hh_size dwelling_type occupancy_status distance_to_drinking_water drainage_sewerage_connection garbage_hh garbage_neighborhood drinking_water_source _Ibirth_yea*, cluster(district) robust
outreg2 using `outputfile_dd_estimations'





********testing for distance to pseudo treatment variable drinking water***********


**********DiD Estimations*******************

local outputfile_pseudo_dd did_pseudo_drinkingwater.xls
set seed 123456789
bootstrap, reps(200): reg distance_to_drinking_water time treat did_estimator, cluster(district) robust
outreg2 using `outputfile_pseudo_dd'

set seed 123456789
bootstrap, reps(200): reg distance_to_drinking_water time treat did_estimator _Ibirth_yea*, cluster(district) robust
outreg2 using `outputfile_pseudo_dd'

set seed 123456789
bootstrap, reps(200): reg distance_to_drinking_water time treat did_estimator hh_head_gender head_employment_status head_highest_grade hh_annual_income hh_annual_transfers hh_annual_exp_food_nondurables hh_annual_exp_durables hh_size dwelling_type occupancy_status drainage_sewerage_connection garbage_hh garbage_neighborhood drinking_water_source _Ibirth_yea*, cluster(district) robust
outreg2 using `outputfile_pseudo_dd'





*****testing for pseudo treatment variable grabage collection from hh*******

local outputfile_pseudo2_dd did_pseudo2_garbage.xls
set seed 123456789
bootstrap, reps(200): reg garbage_hh time treat did_estimator, cluster(district) robust
outreg2 using `outputfile_pseudo2_dd'

set seed 123456789
bootstrap, reps(200): reg garbage_hh time treat did_estimator _Ibirth_yea*, cluster(district) robust
outreg2 using `outputfile_pseudo2_dd'

set seed 123456789
bootstrap, reps(200): reg garbage_hh time treat did_estimator hh_head_gender head_employment_status head_highest_grade hh_annual_income hh_annual_transfers hh_annual_exp_food_nondurables hh_annual_exp_durables hh_size dwelling_type occupancy_status distance_to_drinking_water drainage_sewerage_connection garbage_neighborhood drinking_water_source _Ibirth_yea*, cluster(district) robust
outreg2 using `outputfile_pseudo2_dd'


******************************************************************************************












********************for neonatal care and postnatal care*******************************


*******prenatal**********

ttest prenatal_care if time == 0, by(treat)

*******testing common trend assumption via regression***************


local outputfile_common_trend commontrend_prepost_natal.xls
set seed 12345678

bootstrap, reps(200): reg prenatal_care treat time_trend inter_trend birth_sequence hh_head_gender head_employment_status head_highest_grade hh_annual_income hh_annual_transfers hh_annual_exp_food_nondurables hh_annual_exp_durables hh_size dwelling_type occupancy_status distance_to_drinking_water drainage_sewerage_connection garbage_hh garbage_neighborhood drinking_water_source if time == 0, cluster(district) robust
outreg2 using `outputfile_common_trend'




***********did estimations******************
local outputfile_dd_estimations did_neonatal_bottom1.xls
set seed 123456789
bootstrap, reps(200): reg prenatal_care time treat did_estimator, cluster(district) robust
outreg2 using `outputfile_dd_estimations'

set seed 123456789
bootstrap, reps(200): reg prenatal_care time treat did_estimator _Ibirth_yea*, cluster (district) robust
outreg2 using `outputfile_dd_estimations'

set seed 123456789
bootstrap, reps(200): reg prenatal_care time treat did_estimator birth_sequence hh_head_gender head_employment_status head_highest_grade hh_annual_income hh_annual_transfers hh_annual_exp_food_nondurables hh_annual_exp_durables hh_size dwelling_type occupancy_status distance_to_drinking_water drainage_sewerage_connection garbage_hh garbage_neighborhood drinking_water_source _Ibirth_yea*, cluster(district) robust
outreg2 using `outputfile_dd_estimations'



*******postnatal******

*******testing common trend assumption via regression***************


local outputfile_common_trend commontrend_prepost_natal.xls
set seed 12345678

bootstrap, reps(200): reg postnatal_care_in_six_weeks treat time_trend inter_trend birth_sequence hh_head_gender head_employment_status head_highest_grade hh_annual_income hh_annual_transfers hh_annual_exp_food_nondurables hh_annual_exp_durables hh_size dwelling_type occupancy_status distance_to_drinking_water drainage_sewerage_connection garbage_hh garbage_neighborhood drinking_water_source if time == 0, cluster(district) robust
outreg2 using `outputfile_common_trend'




***********did estimations******************

local outputfile_dd_estimations did_neonatal_bottom1.xls
set seed 123456789
bootstrap, reps(200): reg postnatal_care_in_six_weeks time treat did_estimator, cluster(district) robust
outreg2 using `outputfile_dd_estimations'

set seed 123456789
bootstrap, reps(200): reg postnatal_care_in_six_weeks time treat did_estimator _Ibirth_yea*, cluster (district) robust
outreg2 using `outputfile_dd_estimations'

set seed 123456789
bootstrap, reps(200): reg postnatal_care_in_six_weeks time treat did_estimator birth_sequence hh_head_gender head_employment_status head_highest_grade hh_annual_income hh_annual_transfers hh_annual_exp_food_nondurables hh_annual_exp_durables hh_size dwelling_type occupancy_status distance_to_drinking_water drainage_sewerage_connection garbage_hh garbage_neighborhood drinking_water_source _Ibirth_yea*, cluster(district) robust
outreg2 using `outputfile_dd_estimations'





*******location of prenatal_care****

keep if location_prenatal_care == 1 | location_prenatal_care == 0

*******testing common trend assumption via regression***************


local outputfile_common_trend commontrend_location_prepostcare.xls
set seed 12345678

bootstrap, reps(200): reg location_prenatal_care treat time_trend inter_trend birth_sequence hh_head_gender head_employment_status head_highest_grade hh_annual_income hh_annual_transfers hh_annual_exp_food_nondurables hh_annual_exp_durables hh_size dwelling_type occupancy_status distance_to_drinking_water drainage_sewerage_connection garbage_hh garbage_neighborhood drinking_water_source if time == 0, cluster(district) robust
outreg2 using `outputfile_common_trend'




************DiD estimations ******************

local outputfile_dd_estimations did_location_prenatal.xls
set seed 123456789
bootstrap, reps(200): reg location_prenatal_care time treat did_estimator, cluster(district) robust
outreg2 using `outputfile_dd_estimations'

set seed 123456789
bootstrap, reps(200): reg location_prenatal_care time treat did_estimator _Ibirth_yea*, cluster (district) robust
outreg2 using `outputfile_dd_estimations'

set seed 123456789
bootstrap, reps(200): reg location_prenatal_care time treat did_estimator birth_sequence hh_head_gender head_employment_status head_highest_grade hh_annual_income hh_annual_transfers hh_annual_exp_food_nondurables hh_annual_exp_durables hh_size dwelling_type occupancy_status distance_to_drinking_water drainage_sewerage_connection garbage_hh garbage_neighborhood drinking_water_source _Ibirth_yea*, cluster(district) robust
outreg2 using `outputfile_dd_estimations'


**********location of postnatal_care_in_six_weeks***

	clear
	cd "C:\Users\Patron\OneDrive - UW-Madison\Graduate School\Academics\Fall 2020\PA 888 Social Policy\SP\Analysis Feb 2021\Analysis for 2018\Postpsm\Child delivery"  // setting the current directory
	clear
	
	use "C:\Users\Patron\OneDrive - UW-Madison\Graduate School\Academics\Fall 2020\PA 888 Social Policy\SP\PBS Processed Data\All provinces and regions\1314 and 1819 Combined Feb 2021\postpsm_deliverylocation_till_2018_vf.dta", replace
	

	keep if birth_year >= 2011
	keep if birth_year <= 2018
	
	keep if population_halves == 1
	
	tab postnatal_care_in_six_weeks
	keep if location_postnatal_care == 0 | location_postnatal_care == 1	
	
	
	
*******testing common trend assumption via regression***************
gen time_trend = birth_year - 2011
gen inter_trend = time_trend*treat

local outputfile_common_trend commontrend_location_prepostcare.xls
set seed 12345678

bootstrap, reps(200): reg location_postnatal_care treat time_trend inter_trend birth_sequence hh_head_gender head_employment_status head_highest_grade hh_annual_income hh_annual_transfers hh_annual_exp_food_nondurables hh_annual_exp_durables hh_size dwelling_type occupancy_status distance_to_drinking_water drainage_sewerage_connection garbage_hh garbage_neighborhood drinking_water_source if time == 0, cluster(district) robust
outreg2 using `outputfile_common_trend'


*************DiD Estimations********************	

//creating dummy variable for each year for year fixed effects
 xi i.birth_year
	
local outputfile_dd_estimations did_location_postnatal.xls
set seed 123456789
bootstrap, reps(200): reg location_postnatal_care time treat did_estimator, cluster(district) robust
outreg2 using `outputfile_dd_estimations'

set seed 123456789
bootstrap, reps(200): reg location_postnatal_care time treat did_estimator _Ibirth_yea*, cluster (district) robust
outreg2 using `outputfile_dd_estimations'

set seed 123456789
bootstrap, reps(200): reg location_postnatal_care time treat did_estimator birth_sequence hh_head_gender head_employment_status head_highest_grade hh_annual_income hh_annual_transfers hh_annual_exp_food_nondurables hh_annual_exp_durables hh_size dwelling_type occupancy_status distance_to_drinking_water drainage_sewerage_connection garbage_hh garbage_neighborhood drinking_water_source _Ibirth_yea*, cluster(district) robust
outreg2 using `outputfile_dd_estimations'







******************* for top 3rd of the population**********************************

clear matrix 
	clear
	set more off
	set seed 123456789
	capture log close
	log using "C:\Users\Patron\OneDrive - UW-Madison\Graduate School\Academics\Fall 2020\PA 888 Social Policy\SP\Analysis Feb 2021\Analysis for 2018\Postpsm\Child delivery\Log_delivery_postpsm_top3rd.log", replace  // created a new log file 
	
	use "C:\Users\Patron\OneDrive - UW-Madison\Graduate School\Academics\Fall 2020\PA 888 Social Policy\SP\PBS Processed Data\All provinces and regions\1314 and 1819 Combined Feb 2021\postpsm_deliverylocation_till_2018_vf.dta", replace
	
	
keep if birth_year >= 2011
keep if birth_year <= 2018
	
keep if population_tripartite == 3

*******testing common trend assumption via regression***************

gen time_trend = birth_year - 2011
gen inter_trend = time_trend*treat

local outputfile_common_trend commontrend_reg_top3rd.xls
set seed 12345678

bootstrap, reps(50): reg location_of_birth treat time_trend inter_trend birth_sequence hh_head_gender head_employment_status head_highest_grade hh_annual_income hh_annual_transfers hh_annual_exp_food_nondurables hh_annual_exp_durables hh_size dwelling_type occupancy_status distance_to_drinking_water drainage_sewerage_connection garbage_hh garbage_neighborhood drinking_water_source if time == 0, cluster(district) robust
outreg2 using `outputfile_common_trend'


//creating dummy variable for each year for year fixed effects
 xi i.birth_year

 *********DiD Estimations Tables for delivery location**************

local outputfile_dd_estimations dd_delivery_top3rd.xls
set seed 123456789
bootstrap, reps(50): reg location_of_birth time treat did_estimator, cluster(district) robust
outreg2 using `outputfile_dd_estimations'

set seed 123456789
bootstrap, reps(50): reg location_of_birth time treat did_estimator _Ibirth_yea*, cluster(district) robust
outreg2 using `outputfile_dd_estimations'

set seed 123456789
bootstrap, reps(200): reg location_of_birth time treat did_estimator birth_sequence hh_head_gender head_employment_status head_highest_grade hh_annual_income hh_annual_transfers hh_annual_exp_food_nondurables hh_annual_exp_durables hh_size dwelling_type occupancy_status distance_to_drinking_water drainage_sewerage_connection garbage_hh garbage_neighborhood drinking_water_source _Ibirth_yea*, cluster(district) robust
outreg2 using `outputfile_dd_estimations'


log close



***************************************************************************



